package com.lxhotel.agentmcp.tool;

import com.lxhotel.agentmcp.context.WebContext;
import com.lxhotel.agentmcp.domain.$R;
import com.lxhotel.agentmcp.domain.response.UserResponse;
import com.lxhotel.agentmcp.entity.User;
import com.lxhotel.agentmcp.entity.UserBooking;
import com.lxhotel.agentmcp.mapper.UserBookingMapper;
import com.lxhotel.agentmcp.mapper.UserMapper;
import io.modelcontextprotocol.server.McpSyncServerExchange;
import lombok.val;
import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.mcp.McpToolUtils;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Optional;

import static com.lxhotel.agentmcp.context.WebContext.USER_ID_KEY;


@Service
public class UserTool {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserBookingMapper userBookingMapper;

    @Tool(description = "获取用户信息")
    public UserResponse selectById() {
        User user = userMapper.selectById(WebContext.getUserId());
        UserResponse response = new UserResponse();
        BeanUtils.copyProperties(user, response);
        response.setBookingList(userBookingMapper.selectUserBookingList(WebContext.getUserId()));
        return response;
    }

}
